package com.beyondsoft.dtc.mobile.automation.model;

import com.beyondsoft.dtc.mobile.automation.util.StringUtil;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

/**
 * Created by Robin on 3/11/2016.
 */
public class ApkFile {

	@Expose
	@SerializedName("name")
	private String name;

	@Expose
	@SerializedName("icon")
	private String icon;

	@Expose
	@SerializedName("size")
	private long size = 65535;

	@Expose
	@SerializedName("package")
	private String packageName;

	@Expose
	@SerializedName("activity")
	private String activityName;

	private String localFilePath;
	private String versionName;
	private String versionCode;
	private String platformBuildVersionName;
	private String sdkVersion;
	private String iconLocalFilePath;

	public String getLocalFilePath() {
		return localFilePath;
	}

	public void setLocalFilePath(String localFilePath) {
		this.localFilePath = localFilePath;
	}

	public String getPackageName() {
		return packageName;
	}

	public void setPackageName(String packageName) {
		this.packageName = packageName;
	}

	public String getVersionName() {
		return versionName;
	}

	public void setVersionName(String versionName) {
		this.versionName = versionName;
	}

	public String getVersionCode() {
		return versionCode;
	}

	public void setVersionCode(String versionCode) {
		this.versionCode = versionCode;
	}

	public String getPlatformBuildVersionName() {
		return platformBuildVersionName;
	}

	public void setPlatformBuildVersionName(String platformBuildVersionName) {
		this.platformBuildVersionName = platformBuildVersionName;
	}

	public String getSdkVersion() {
		return sdkVersion;
	}

	public void setSdkVersion(String sdkVersion) {
		this.sdkVersion = sdkVersion;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		String tmp = name;
		try {
			tmp = new String(name.getBytes("UTF-8"));
		} catch (Exception e) {
			e.printStackTrace();
		}
		this.name = tmp;
	}

	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public String getIconLocalFilePath() {
		return iconLocalFilePath;
	}

	public void setIconLocalFilePath(String iconLocalFilePath) {
		this.iconLocalFilePath = iconLocalFilePath;
	}

	public String getActivityName() {
		return activityName;
	}

	public void setActivityName(String activityName) {
		this.activityName = activityName;
	}

	public long getSize() {
		return size;
	}

	public void setSize(long size) {
		this.size = size;
	}

	public boolean isDownloaded() {
		return size > 0 && !StringUtil.isEmpty(localFilePath);
	}

	public boolean isParsed() {
		return !StringUtil.isEmpty(packageName)
				&& !StringUtil.isEmpty(activityName);
	}

	@Override
	public String toString() {
		return "ApkFile{" + "localFilePath='" + localFilePath + '\''
				+ ", packageName='" + packageName + '\'' + ", versionName='"
				+ versionName + '\'' + ", versionCode='" + versionCode + '\''
				+ ", platformBuildVersionName='" + platformBuildVersionName
				+ '\'' + ", sdkVersion='" + sdkVersion + '\'' + ", name='"
				+ name + '\'' + ", icon='" + icon + '\'' + ", activityName='"
				+ activityName + '\'' + '}';
	}
}
